# demo03_str_format.py
name, age = "zhangsan", 18
print("name: " + name + ", age: " + str(age))
# 字符串的格式化
# 1. %s: 字符串类型的坑   %d: 整数类型的坑
print("name: %s, age: %d" % (name, age))
#    %f: 浮点数类型的坑  %.2f: 小数点后保留两位小数(四舍五入)
print("num01: %f, num02: %f" % (1, 22.22))
print("num01: %.2f, num02: %.2f" % (1, 22.229))
# 不知道数据是什么类型，直接用%s代替，准没问题
print("name: %s, age: %s, list: %s" % ("ls", 20, [1, 2]))
# 2. format
print("name: {}, age: {}".format("zhangsan", 18))

